package com.app.couponsharelife.ui.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.WindowManager
import android.widget.ImageView
import android.widget.TextView
import com.app.couponsharelife.R
import com.app.couponsharelife.ui.listener.OnClickListener

/**
 * Created by guluwa on 2018/12/10.
 */
class CollectCancelDialog(context: Context, themeResId: Int, val listener: OnClickListener) : Dialog(context, themeResId) {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.collect_dialog)
        initView()
    }

    private fun initView() {
        findViewById<ImageView>(R.id.ivCloseDialog).setOnClickListener {
            dismiss()
        }
        findViewById<TextView>(R.id.tvCancel).setOnClickListener {
            dismiss()
            listener.click(0, "")
        }
        findViewById<TextView>(R.id.tvShare).setOnClickListener {
            dismiss()
            listener.click(1, "")
        }

        window!!.setWindowAnimations(R.style.scale_in_alpha_out)
        setCanceledOnTouchOutside(true)

        //设置dialog没有边距
        window!!.decorView.setPadding(0, 0, 0, 0)
        val lp = window!!.attributes
        lp.width = WindowManager.LayoutParams.MATCH_PARENT
        lp.height = WindowManager.LayoutParams.WRAP_CONTENT
        window!!.attributes = lp
    }
}